import { decrypt } from '@/utils/encrypt'

const state = {
  userInfo: {}, //用户信息
  routerChecked: [],
}

const getters = {}

const mutations = {
  loginInfo(state, data) {
    //用户信息
    const { id, key, user, pass, label, userId, orgId, token } = data
    state.userInfo = {
      id,
      key,
      user,
      pass,
      label,
      userId,
      orgId,
      token: decrypt(token),
    }
  },

  setRouterChecked(state, data) {
    state.routerChecked = data
  },

  clearVuex(state, data) {
    state.userInfo = {}
  },

  clearRouterChecked(state, data) {
    state.routerChecked = []
  },
}

const actions = {}

export default {
  state,
  actions,
  getters,
  mutations,
}
